$(function () {
    $(".ilike-m").live("click", function () {
        if ($.guang.dialog.isLogin()) {
            var b = $(this);
            if ("disable" != b.data("enable")) {
                b.data("enable", "disable");
                setTimeout(function () {
                    b.data("enable", "enable")
                }, 1E3);
                var a = b.attr("data-type"), c = b.attr("data-proid"), d = b.parent().parent().find(".like-count:first"), f = null;
                $.guang.judgement.repeatIdentityClk = function (a) {
                    b.data("enable", "enable");
                    $("#cmtDialog")[0] && (clearTimeout(f), $("#cmtDialog").remove());
                    var d;
                    d = '<div id="cmtDialog" class="c-dialog" style="width:180px"><p class="title clearfix"><a class="cmtclose fr" href="javascript:;">x</a>&gt;_&lt;喜欢过了~</p>' +
                        ('<a class="sbl-btn speakmore comment-tag" data-type="3" data-proid="' + c + '">再说两句</a>');
                    $("body").append(d + "</div>");
                    $(".cmt-txa").focus(function () {
                        var b = $("#cmtDialog").offset().top;
                        $("#cmtDialog").css({top:b - 50 + "px", height:104});
                        $(this).height(50);
                        $(".cmt-txa").unbind("focus")
                    });
                    a = $.guang.util.getPosition(a).topMid();
                    d = $("#cmtDialog").outerWidth();
                    var e = $("#cmtDialog").outerHeight();
                    $("#cmtDialog").css({left:a.x - d / 2 + "px", top:a.y - e - 12 + "px"}).fadeIn();
                    f = setTimeout(function () {
                            $("#cmtDialog").fadeOut().remove()
                        },
                        3E3);
                    $(".comment-tag").unbind();
                    $(".comment-tag").bind("click", function () {
                        $.guang.cmt.commentAndAddTagsSubmitOkClk = function () {
                        };
                        var a = b.prev().attr("title"), d = b.prev().find("img").attr("src"), c = b.prev().attr("href").indexOf("http") >= 0 ? b.prev().attr("href") : "http://" + window.location.host + b.prev().attr("href");
                        $.guang.cmt.commentAndAddTags($(this), "", "", a, d, c, [], "fromNonDetail")
                    })
                };
                $.guang.judgement.identityCallback = function (a) {
                    b.data("enable", "enable");
                    d.text(parseInt(d.text()) + 1);
                    var e;
                    e = '<div id="cmtDialog" class="c-dialog"><p class="title clearfix"><a class="cmtclose fr" href="javascript:;">x</a>喜欢了~</p>' +
                        ('<a class="sbl-btn speakmore comment-tag" data-type="0" data-proid="' + c + '">再说两句</a>');
                    $("body").append(e + "</div>");
                    $(".cmt-txa").focus(function () {
                        var b = $("#cmtDialog").offset().top;
                        $("#cmtDialog").css({top:b - 50 + "px", height:104});
                        $(this).height(50);
                        $(".cmt-txa").unbind("focus")
                    });
                    a = $.guang.util.getPosition(a).topMid();
                    e = $("#cmtDialog").outerWidth();
                    var g = $("#cmtDialog").outerHeight();
                    $("#cmtDialog").css({left:a.x - e / 2 + "px", top:a.y - g - 12 + "px"}).fadeIn();
                    f = setTimeout(function () {
                            $("#cmtDialog").fadeOut().remove()
                        },
                        3E3);
                    $(".comment-tag").bind("click", function () {
                        $.guang.cmt.commentAndAddTagsSubmitOkClk = function () {
                        };
                        var a = b.prev().attr("title"), d = b.prev().find("img").attr("src"), c = 0 <= b.prev().attr("href").indexOf("http") ? b.prev().attr("href") : "http://" + window.location.host + b.prev().attr("href");
                        $.guang.cmt.commentAndAddTags(b, "", "", a, d, c, [], "fromNonDetail")
                    })
                };
                $.guang.judgement.identityOper(b, c, a)
            }
        }
    });
    if ($("#J_Pagination")[0]) {
        var f = $("#J_Pagination");
        f.pagination(5E3 >= goodsPage.sumGoodsNum ? goodsPage.sumGoodsNum :
            5E3, {num_edge_entries:2, num_display_entries:4, callback:function () {
            var a = f.find("a"), c = f.find("a.prev"), e = f.find("a.next"), d = goodsPage.pageUrl;
            a.each(function () {
                $(this).attr("href", goodsPage.pagePath + d + (0 < d.indexOf("?") ? "&" : "?") + "p=" + $(this).text())
            });
            c[0] && c.attr("href", goodsPage.pagePath + d + (0 < d.indexOf("?") ? "&" : "?") + "p=" + (parseInt(goodsPage.curPageNum) - 1));
            e[0] && e.attr("href", goodsPage.pagePath + d + (0 < d.indexOf("?") ? "&" : "?") + "p=" + (parseInt(goodsPage.curPageNum) + 1));
            a.live("click", function () {
                window.location.href =
                    $(this).attr("href")
            });
            "" != goodsPage.scene && $("<span>...</span>").insertBefore(e);
            return!1
        }, items_per_page:100, current_page:parseInt(goodsPage.curPageNum) - 1, isJump:!0})
    }
    var a = window.location.href;
    if (-1 == a.indexOf("cag") && -1 == a.indexOf("scene") && !/(xihuan)\/?$/.test(a) && (-1 != a.indexOf("tag") || -1 != a.indexOf("gallery") && -1 != a.indexOf("tag"))) {
        var c = $("#J_GoodsTitle").offset().top - 45;
        $("html, body").animate({scrollTop:(a.indexOf("gallery"), c)}, 120)
    }
    if ($("#J_NeedsPanel")[0]) {
        var e = $("#J_NeedsPanel"), g =
            $("#J_NeedsPage"), a = e.find("ul").length, c = e.find("ul:first").outerWidth(), j = 4 * c;
        e.css("width", a * c + 10);
        if (4 < a) {
            g.css("display", "block");
            for (var a = Math.ceil(a / 4), c = "", h = 1; h < a; h++)c += "<li><a>" + (h + 1) + "</a></li>";
            g.append(c);
            g.find("a").click(function (a) {
                a.preventDefault();
                a = parseInt($(this).html()) - 1;
                a *= j;
                g.find("a").removeClass("current");
                $(this).addClass("current");
                e.animate({left:-a}, 500)
            })
        }
    }
    if ($("#J_BrandsTabTitle")[0]) {
        a = $("#J_BrandsTabTitle");
        a.tabs("#J_BrandsTabPanel li", {event:"mouseover", rotate:!0});
        var k = a.data("tabs"), i = function () {
            tabInterval = setInterval(function () {
                k.next()
            }, 4E3)
        };
        i();
        a.find("li").hover(function () {
            clearInterval(tabInterval)
        }, function () {
            i()
        })
    }
});
